DELICIOUS ORDER
スコアの昇順にソートする。
https://gyazo.com/eb52d1e1a400ce518a694dffe32086c9
メモ
疑似コード
code:sort.rb
arr = 251, 216, 20, 166, 63, 202, 195, 231, 185, 108, 229, 84, 100, 139, 199 i = 0
while true
break if i >= (arr.size - 1)
j = 0
while true
break if j >= (arr.size - 1)
if a > b
end
j = j + 1
end
i = i + 1
end
puts arr
コード
code:foo
const add 0
const add_ri 64
const add_ii 192
const sub 1
const sub_ri 65
const jeq 32
const jeq_ri 96
const jeq_ii 224
const jlt 34
const jlte 35
const jgt 36
const jgte 37
const jgte_ri 101
const sw 16
const sw_ri 80
const lw 17
const lw_ri 81
const call 8
const ret 9
const r0 0
const r1 1
const r2 2
const r3 3
const r4 4
const r5 5
const sp 5
const sp_offset 4
const counter 6
const input 7
const output 7
const i 1
const v 3
# init
add_ii
0
0
i
# load scores
label load_scores
jgte_ri
i
15
break_load_scores
add
input
r0
v
sw
i
r0
v
add_ri
i
1
i
jeq
r0
r0
load_scores
label break_load_scores
const i 1
const j 2
const a 3
const b 4
const N_1 14
# i = 0
add_ii
0
0
i
label i_loop
jgte_ri
i
N_1
break_i_loop
add_ii
0
0
j
label j_loop
jgte_ri
j
N_1
break_j_loop
lw_ri
j
0
a
lw_ri
j
1
b
jgt
b
a
no_swap
sw_ri
j
1
a
sw_ri
j
0
b
label no_swap
add_ri
j
1
j
jeq
r0
r0
j_loop
label break_j_loop
add_ri
i
1
i
jeq
r0
r0
i_loop
label break_i_loop
# output
add_ii
0
0
i
label out_loop
jgte_ri
i
15
break_out_loop
lw
i
r0
v
add
v
r0
output
add_ri
i
1
i
jeq
r0
r0
out_loop
label break_out_loop